package org.sixtynine.stock.dao;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Query;
import javax.persistence.TypedQuery;

import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.BaseEntity;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilanka
 * 
 * @param <E>
 * @param <I>
 */
@Transactional(readOnly = true)
public interface AbstractDao<E, I extends Serializable> {

	void saveList(List<BaseEntity> objs);
	
	E findById(I id);

	E findById(I id, Class<E> clazz);

	void saveOrUpdate(E e);

	void delete(E e);

	List<E> findByCriteria(Criterion criterion);

	List<E> findByCriteria(Criteria criteria);

	List<E> findByCriteria(Criterion criterion, Class<E> clazz);

	List<E> findByCriteria(Class<E> clazz, Criterion... criterion);

	List<E> findAll(Class<E> clazz);

	/** this will find the latest records of the given class */
	List<E> findLatestRecords(int numResuts, Class<E> clazz, String orderBy,
			Criterion... criterion);

	public Page<E> getPagedData(TypedQuery<E> query, Query totalQuery,
			int start, int count);

	public Page<E> getPagedData(TypedQuery<E> query, Query totalQuery,
			GridPramDTO gridPramDTO);

	public Page<E> getPagedData(TypedQuery<E> query);

	public Page<E> findAllWithPaging(Class<E> clazz, GridPramDTO gridPramDTO);

	public Page<E> findByCriteria(Class<E> clazz, GridPramDTO gridPramDTO,
			Criterion... criterion);

	public Page<E> findByCriteria(Criteria criteria, GridPramDTO gridPramDTO);
}
